package com.zhuss.meeting.apply;

import com.zhuss.bean.bo.meeting.apply.*;
import com.zhuss.common.OperateService;
import com.zhuss.common.Processor;
import com.zhuss.exception.WpsException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

/**
 * @Author: zhushanshuo
 * @Date: 2020/2/12 19:24
 */
@Component("applyOperateService")
public class ApplyOperateService implements OperateService<Void, Object> {

    @Autowired
    @Qualifier("applyCreate")
    private Processor<Object, CreateApplyBo> applyCreate;

    @Autowired
    @Qualifier("applyUpdate")
    private Processor<Object, UpdateApplyBo> applyUpdate;

    @Autowired
    @Qualifier("applyDelete")
    private Processor<Object, DeleteApplyBo> applyDelete;

    @Autowired
    @Qualifier("applyUse")
    private Processor<Object, UseApplyBo> applyUse;

    @Autowired
    @Qualifier("applyCancel")
    private Processor<Object, CancelApplyBo> applyCancel;

    @Autowired
    @Qualifier("applyEvaluate")
    private Processor<Object, EvaluateApplyBo> applyEvaluate;

    @Autowired
    @Qualifier("applyChange")
    private Processor<Object, ChangeApplyBo> applyChange;

    @Autowired
    @Qualifier("applySubmit")
    private Processor<Object, SubmitApplyBo> applySubmit;

    @Autowired
    @Qualifier("applyRevoke")
    private Processor<Object, RevokeApplyBo> applyRevoke;

    @Override
    @Transactional(rollbackFor = Exception.class)
    public Void create(Object o) throws WpsException {
        CreateApplyBo bo = (CreateApplyBo) o;
        applyCreate.process(bo);
        return null;
    }

    @Override
    public Void update(Object o) throws WpsException {
        UpdateApplyBo bo = (UpdateApplyBo) o;
        applyUpdate.process(bo);
        return null;
    }

    @Override
    public Void delete(Object o) throws WpsException {
        DeleteApplyBo bo = (DeleteApplyBo) o;
        applyDelete.process(bo);
        return null;
    }

    /**
     * 确认使用会议室
     * @param o
     * @return
     * @throws WpsException
     */
    @Transactional(rollbackFor = Exception.class)
    public Void applyUse(Object o) throws WpsException {
        UseApplyBo bo = (UseApplyBo) o;
        applyUse.process(bo);
        return null;
    }

    /**
     * 取消使用会议室
     * @param o
     * @return
     * @throws WpsException
     */
    @Transactional(rollbackFor = Exception.class)
    public Void applyCancel(Object o) throws WpsException {
        CancelApplyBo bo = (CancelApplyBo) o;
        applyCancel.process(bo);
        return null;
    }

    /**
     * 会议室评价
     * @param o
     * @return
     * @throws WpsException
     */
    @Transactional(rollbackFor = Exception.class)
    public Void applyEvaluate(Object o) throws WpsException {
        EvaluateApplyBo bo = (EvaluateApplyBo) o;
        applyEvaluate.process(bo);
        return null;
    }

    /**
     * 更换会议室
     * @param o
     * @return
     * @throws WpsException
     */
    @Transactional(rollbackFor = Exception.class)
    public Void applyChange(Object o) throws WpsException {
        ChangeApplyBo bo = (ChangeApplyBo) o;
        applyChange.process(bo);
        return null;
    }

    /**
     * 提交会议室申请
     * @param o
     * @return
     * @throws WpsException
     */
    @Transactional(rollbackFor = Exception.class)
    public Void applySubmit(Object o) throws WpsException {
        SubmitApplyBo bo = (SubmitApplyBo) o;
        applySubmit.process(bo);
        return null;
    }

    /**
     * 撤销会议室申请
     * @param o
     * @return
     * @throws WpsException
     */
    @Transactional(rollbackFor = Exception.class)
    public Void applyRevoke(Object o) throws WpsException {
        RevokeApplyBo bo = (RevokeApplyBo) o;
        applyRevoke.process(bo);
        return null;
    }

}
